const Queue = require('bull');

class App {
    constructor(app) {
        this.app = app;
        this.app.messenger.once('egg-ready', () => {

        });

        this.app.messenger.on('worker_invoke', ({ method, data, callbackId }) => {
            if (callbackId) {
                this.app.messenger.sendToAgent(callbackId, {
                    data: {
                        id: 1000,
                    }
                });
            }
        });
    }

    async serverDidReady() {
        const testQueue = new Queue("testQueue", {
            redis: { port: 6379, host: '127.0.0.1', password: null }
        });
        this.app.testQueue = testQueue;
    }
}

module.exports = App;